]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
statusMenu: Use the screensaver's dbus interface directly
authorAdel Gadllah <adel.gadllah@gmail.com>
Wed, 9 Mar 2011 20:59:26 +0000 (21:59 +0100)
committerAdel Gadllah <adel.gadllah@gmail.com>
Wed, 9 Mar 2011 20:59:26 +0000 (21:59 +0100)
Use the dbus interface instead of calling gnome-screensaver-command.

https://bugzilla.gnome.org/show_bug.cgi?id=643357

js/ui/statusMenu.js

index 60643e3d030f673e75320bf16de0f8feb62a0ad7..adf5491f74936d688354eee6cc7335cde0eb1698 100644 (file)
@@ -1,6 +1,7 @@
 /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
 
 const Gdm = imports.gi.Gdm;
+const DBus = imports.dbus;
 const GLib = imports.gi.GLib;
 const Lang = imports.lang;
 const Shell = imports.gi.Shell;
@@ -16,6 +17,16 @@ const PanelMenu = imports.ui.panelMenu;
 const PopupMenu = imports.ui.popupMenu;
 const Util = imports.misc.util;
 
+const BUS_NAME = 'org.gnome.ScreenSaver';
+const OBJECT_PATH = '/org/gnome/ScreenSaver';
+
+const ScreenSaverInterface = {
+    name: BUS_NAME,
+    methods: [ { name: 'Lock', inSignature: '' } ]
+};
+
+let ScreenSaverProxy = DBus.makeProxyClass(ScreenSaverInterface);
+
 // Adapted from gdm/gui/user-switch-applet/applet.c
 //
 // Copyright (C) 2004-2005 James M. Cape <jcape@ignore-your.tv>.
@@ -43,7 +54,7 @@ StatusMenuButton.prototype = {
         this._account_mgr = Tp.AccountManager.dup()
 
         this._upClient = new UPowerGlib.Client();
-
+        this._screenSaverProxy = new ScreenSaverProxy(DBus.session, BUS_NAME, OBJECT_PATH);
         this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
 
         this._iconBox = new St.Bin();
@@ -188,7 +199,7 @@ StatusMenuButton.prototype = {
 
     _onLockScreenActivate: function() {
         Main.overview.hide();
-        Util.spawn(['gnome-screensaver-command', '--lock']);
+        this._screenSaverProxy.LockRemote();
     },
 
     _onLoginScreenActivate: function() {